﻿using log4net.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aribaccio.Logger
{
    /// <summary>
    /// 日志管理中心
    /// </summary>
    public class LoggerMgrcore : Singleton<LoggerMgrcore>
    {
        /// <summary>
        /// 日志管理者实例
        /// </summary>
        protected LoggerLeader? LoggerInstance { get; set; }

        /// <summary>
        /// 构造函数
        /// </summary>
        public LoggerMgrcore()
        {

        }

        public void Register(LoggerLeader argLogger)
        {
            this.LoggerInstance = argLogger;
        }

        /// <summary>
        /// 写入常规日志消息
        /// </summary>
        /// <param name="argMessage">消息内容</param>
        public void WriteInfo(string argMessage)
        {
            this.LoggerInstance?.WriteInfo(argMessage);
        }

        /// <summary>
        /// 写入调试日志消息
        /// </summary>
        /// <param name="argMessage">消息内容</param>
        public void WriteDebug(string argMessage)
        {
            this.LoggerInstance?.WriteDebug(argMessage);
        }

        /// <summary>
        /// 写入告警日志消息
        /// </summary>
        /// <param name="argMessage">消息内容</param>
        public void WriteWarning(string argMessage)
        {
            this.LoggerInstance?.WriteWarning(argMessage);
        }

        /// <summary>
        /// 写入错误/异常日志消息
        /// </summary>
        /// <param name="argMessage">消息内容</param>
        /// <param name="argException">消息异常对象</param>
        public void WriteError(string argMessage, Exception? argException = null)
        {
            this.LoggerInstance?.WriteError(argMessage, argException);
        }

        /// <summary>
        /// 写入日志消息
        /// </summary>
        /// <param name="argMessage">消息内容</param>
        /// <param name="argLevel">消息等级</param>
        /// <param name="argException">消息异常对象</param>
        public void Write(string argMessage, Level argLevel, Exception? argException = null)
        {
            this.LoggerInstance?.Write(argMessage, argLevel, argException);
        }
    }
}
